<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="mobile">
<input type="button" value="点我" onclick="dosth()">
<div id="out"></div>
<script>

function dosth(){
    var mobileObj = document.getElementById('mobile');
    var m = mobileObj.value;
    var s = m.substr(3,4);
    var r = m.replace(s,'****');

    var outObj = document.getElementById('out');
    outObj.innerHTML = r;
    //console.log(r);
    //document.writeln(r)
}

</script>
</body>
</html>